package org.wu.framework.authorization.platform.application.assembler;

import org.wu.framework.authorization.platform.application.command.SysRoleCommand;
import org.wu.framework.authorization.platform.application.dto.SysRoleDTO;
import org.wu.framework.authorization.platform.domain.model.sys.role.SysRole;
import org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyAssembler;

/**
 * describe 角色
 *
 * @author Jia wei Wu
 * @date 2023/05/17 11:19 晚上
 * @see DefaultDDDLazyAssembler
 **/

public class SysRoleDTOAssembler {


    /**
     * describe 应用层入参转换成 持久层入参
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/
    public static SysRole toRole(SysRoleCommand sysRoleCommand) {
        if (null != sysRoleCommand) {
            SysRole sysRole = new SysRole();
            sysRole.setCode(sysRoleCommand.getCode());
            sysRole.setCreateTime(sysRoleCommand.getCreateTime());
            sysRole.setId(sysRoleCommand.getId());
            sysRole.setIsDeleted(sysRoleCommand.getIsDeleted());
            sysRole.setStatus(sysRoleCommand.isStatus());
            sysRole.setName(sysRoleCommand.getName());
            sysRole.setParentCode(sysRoleCommand.getParentCode());
            sysRole.setUpdateTime(sysRoleCommand.getUpdateTime());
            return sysRole;
        }
        return null;
    }

    /**
     * describe 持久层领域对象转换成DTO对象
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/
    public static SysRoleDTO fromRole(SysRole sysRole) {
        if (null != sysRole) {
            SysRoleDTO sysRoleDTO = new SysRoleDTO();
            sysRoleDTO.setCode(sysRole.getCode());
            sysRoleDTO.setCreateTime(sysRole.getCreateTime());
            sysRoleDTO.setId(sysRole.getId());
            sysRoleDTO.setIsDeleted(sysRole.getIsDeleted());
            sysRoleDTO.setStatus(sysRole.isStatus());
            sysRoleDTO.setName(sysRole.getName());
            sysRoleDTO.setParentCode(sysRole.getParentCode());
            sysRoleDTO.setUpdateTime(sysRole.getUpdateTime());
            return sysRoleDTO;
        }
        return null;
    }

}